home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
050
/
madtrb34.arc
/
FLCOPY.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1986-04-06
|
1KB
|
54 lines
{
FileCopy: copies a file from one name to another. It is called like this:
Success:=FileCopy(SourceName,DestName);
For instance,
BackupOK:=FileCopy(FName,FName+'.BAK');
or
If Not FileCopy(SourceDrive+'PART3.OVR',DestDrive+'PART3.OVR') Then
Abort('Unable to copy overlay 3, aborting installation');
(That last should not be considered an example of how to write a good
installation program!!)
- Bela Lubkin
CompuServe 76703,3015
2/6/86
}
Type _FC_String66=String[66];
Function FileCopy(Source,Dest: _FC_String66): Boolean;
Const
BufSize=16384; { Powers of 2 are good here }
Var
SF,DF: File;
Buffer: Array [1..BufSize] Of Byte;
Error: Boolean;
RecsRead: Integer;
Begin
FileCopy:=False;
Assign(SF,Source);
{$I-}
Reset(SF,1);
If IOResult<>0 Then Exit;
Assign(DF,Dest);
Rewrite(DF,1);
If IOResult<>0 Then
Begin
Close(SF);
Exit;
End;
Error:=False;
Repeat
BlockRead(SF,Buffer,BufSize,RecsRead);
If IOResult<>0 Then Error:=True;
If Not Error And (RecsRead<>0) Then BlockWrite(DF,Buffer,RecsRead);
If IOResult<>0 Then Error:=True;
Until (RecsRead<BufSize) Or Error;
Close(SF);
Close(DF);
{$I+}
FileCopy:=Not Error;
End;